package command

import (
	"fmt"

	"code.google.com/p/microtool/basic/dialect"
	"code.google.com/p/microtool/util/stringset"
)

// The listDialects command outputs a sorted list of all known BASIC dialects
// within Microtool.
var listDialects = &Command{
	Name: "listdialects",
	Info: "List all active BASIC dialects.",
	Fn:   listDialectsImpl,
}

// listDialectsImpl implements the listdialects command.
func listDialectsImpl(_, _ string) error {
	ss := stringset.NewSet()
	for name := range dialect.Active {
		ss.Add(name)
	}
	for _, name := range ss.OrderedSlice() {
		fmt.Printf("%-20s  %s\n", name, dialect.Active[name].Info())
	}
	return nil
}

